package com.itita.ww2.handler.requesthandler.science;

import java.sql.SQLException;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.itita.ww2.core.WW2Exception;
import com.itita.ww2.utils.handler.IRequestOper;

//
//import com.smartfoxserver.v2.entities.User;
//import com.smartfoxserver.v2.entities.data.ISFSObject;
//import com.smartfoxserver.v2.entities.data.SFSObject;
//import com.itita.ww2.core.MessageHandler;
//import com.itita.ww2.enums.MsgCode;
//import com.itita.ww2.game.R;
//import com.itita.ww2.game.UserService;
//import com.itita.ww2.model.user.DevTime.DevTimeType;
//import com.itita.ww2.model.user.UserProfile;
//import com.itita.ww2.utils.DevKeyUtil;
//import com.itita.ww2.utils.handler.IRequestOper;
//
///**
// * 科技升级
// * @author NorthLan
// *
// */
public class ScienceUpgrade implements IRequestOper {
	//
	@Override
	public boolean execute(String requestCMD, User user, ISFSObject params) throws WW2Exception, SQLException {
		//		UserProfile userProfile = UserService.getInstance().getUserProfile(user);
		//		int uid = userProfile.getUid();
		//		String scCode = params.getUtfString(R.DATA_KEY_CODE);
		//
		//		// 
		//		ISFSObject backObj = new SFSObject();
		//		backObj.putInt(R.DATA_KEY_COUNTER, params.getInt(R.DATA_KEY_COUNTER));
		//		
		//		// 用户是否在升级该单位
		//		if (userProfile.getTimeManager().isDevTimeExists(DevTimeType.UPGRADE, scCode)) {
		//			MessageHandler.getInstance().sendMsg(requestCMD, backObj, user, MsgCode.BASEMAP_UNIT_UPGRADING, false);
		//			return false;
		//		}
		//
		//		// 资源
		//		int level = UserService.getInstance().getUserScienceLevel(uid, scCode);
		//
		//		// 判断用户是否具备升级条件,包括资源条件
		//		if (!UserService.getInstance().isBypassLimit(userProfile, scCode, level)) {
		//			MessageHandler.getInstance().sendMsg(requestCMD, backObj, user, MsgCode.BASEMAP_REQUIRE_NOT_REACHED, false);
		//			return false;
		//		}
		//
		//		// 消耗资源
		//		UserService.getInstance().consumeResOfBLL(userProfile, scCode, level);
		//		// 推资源消息
		//		userProfile.getResManager().sync();
		//		// 加入时间管理
		//		String devKey = DevKeyUtil.combineKey(DevTimeType.UPGRADE.toString(), scCode);
		//		long endTime = UserService.getInstance().addDevTimeOfBLL(uid, devKey, scCode, level);
		//
		//		//发送成功信息
		//		backObj.putLong("endTime", endTime);
		//		backObj.putUtfString("key", devKey);
		//		//		backObj.putInt("count", 1);
		//		MessageHandler.getInstance().sendMsg(requestCMD, backObj, user, null, true);
		return true;
	}

}
